package com.ruoyi.project.cms.knowledgemanagement.controller;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cms.knowledgemanagement.domain.KnowledgeBenchmarking;
import com.ruoyi.project.cms.knowledgemanagement.service.IKnowledgeBenchmarkingService;
import com.ruoyi.project.system.role.domain.Role;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/knowledgemanagement/knowledgeBenchmarking")
public class KnowledgeBenchmarkingController extends BaseController {

    @Autowired
    private IKnowledgeBenchmarkingService iKnowledgeBenchmarkingService;


    String prefix = "/cms/knowledgemanagement";

    @GetMapping("")
    public String knowledge(){

        return prefix+"/benchmarking";
    }

    /**
     * 查询
     * @param knowledgeBenchmarking
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KnowledgeBenchmarking knowledgeBenchmarking){
        startPage();
        List<KnowledgeBenchmarking> list = iKnowledgeBenchmarkingService.findMore(knowledgeBenchmarking);
        return getDataTable(list);
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids){
        try
        {
            return toAjax(iKnowledgeBenchmarkingService.deleteRoleByIds(ids));
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
    }


    /**
     * 查看
     */
    @GetMapping("/detail/{project_id}")
    public String edit(@PathVariable("project_id") Long project_id, ModelMap mmap)
    {
        mmap.put("KnowledgeBenchmarking", iKnowledgeBenchmarkingService.selectKnowledgeBenchmarkingById(project_id));
        return prefix + "/detail";
    }




    /**
     * 判断是否为标杆项目
     */
    @PostMapping("/changeStatus")
    @ResponseBody
    public AjaxResult changeStatus( KnowledgeBenchmarking knowledgeBenchmarking)
    {
        return toAjax(iKnowledgeBenchmarkingService.changeStatus(knowledgeBenchmarking));
    }

}
